﻿<UserControl x:Class="CI.PW.Controls.NeuralNetworkWPF"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:graphsharp="clr-namespace:GraphSharp.Controls;assembly=GraphSharp.Controls"
             xmlns:zoom="clr-namespace:WPFExtensions.Controls;assembly=WPFExtensions" xmlns:converter="clr-namespace:WPFExtensions.Converters;assembly=WPFExtensions" x:Name="root">
    <Control.Resources>
        <converter:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" />
    </Control.Resources>
    <GroupBox Header="Neural Network">
        <zoom:ZoomControl>
            <zoom:ZoomControl.Resources>
                <ControlTemplate x:Key="Neuron">
                    <Button Command="{Binding ShowExtendedData}">
                        <Border BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            Background="{TemplateBinding Background}"
                            ToolTip="{TemplateBinding ToolTip}">
                            <StackPanel>
                                <TextBlock Text="{Binding}"/>
                                <Grid Visibility="{Binding Path=IsNeuron, Converter={StaticResource BoolToVisibilityConverter}}">
                                    <Grid.RowDefinitions>
                                        <RowDefinition/>
                                        <RowDefinition/>
                                    </Grid.RowDefinitions>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition/>
                                        <ColumnDefinition/>
                                        <ColumnDefinition/>
                                        <ColumnDefinition/>
                                    </Grid.ColumnDefinitions>
                                    <TextBlock Grid.Column="0" Grid.Row="0" Text="Current :"/>
                                    <TextBlock Grid.Column="1" Grid.Row="0" Text="{Binding CurrentValue}"/>
                                    <TextBlock Grid.Column="2" Grid.Row="0" Text="Thresold :"/>
                                    <TextBlock Grid.Column="3" Grid.Row="0" Text="{Binding ThresholdValue}"/>
                                    <TextBlock Grid.Column="0" Grid.Row="1" Text="Last Eval :"/>
                                    <TextBlock Grid.Column="1" Grid.Row="1" Text="{Binding LastEvaluationValue}"/>
                                    <TextBlock Grid.Column="2" Grid.Row="1" Text="Last Act :"/>
                                    <TextBlock Grid.Column="3" Grid.Row="1" Text="{Binding LastActivationValue}"/>
                                </Grid>
                                <Grid Visibility="{Binding Path=IsSynapse, Converter={StaticResource BoolToVisibilityConverter}}">
                                    <Grid.RowDefinitions>
                                        <RowDefinition/>
                                    </Grid.RowDefinitions>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition/>
                                        <ColumnDefinition/>
                                    </Grid.ColumnDefinitions>
                                    <TextBlock Grid.Column="0" Grid.Row="0" Text="Value :"/>
                                    <TextBlock Grid.Column="1" Grid.Row="0" Text="{Binding SynapseValue}"/>

                                </Grid>
                            </StackPanel>
                        </Border>
                    </Button>
                </ControlTemplate>
                <Style TargetType="{x:Type graphsharp:VertexControl}">
                    <Setter Property="Template" Value="{StaticResource Neuron}"/>
                </Style>
            </zoom:ZoomControl.Resources>
            <graphsharp:GraphLayout
                x:Name="graphLayout"
                Graph="{Binding Path=GraphToVisualize}"
                LayoutAlgorithmType="EfficientSugiyama"
                OverlapRemovalAlgorithmType="FSA"
                HighlightAlgorithmType="Simple" />
        </zoom:ZoomControl>
    </GroupBox>
</UserControl>
